package cn.edu.njust.alg.jisuanke;

import java.util.Scanner;

public class Main_005 {
	

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int m, n, t;
		m = sc.nextInt();
		n = sc.nextInt();
		t = sc.nextInt();
		int[][] mat = new int[m][n];
		for (int i = 0; i < mat.length; i++) {
			for (int j = 0; j < mat[i].length; j++) {
				mat[i][j] = sc.nextInt();
			}
		}
		int temp;
		int col,row;
		if (t == 0) {// T为0时表示左右翻转，为1时表示上下翻转
			row=mat.length;
			for (int i = 0; i < mat.length; i++) {
				col=mat[i].length;
				for (int j = 0; j < mat[i].length/2; j++) {
					temp=mat[i][j];
					mat[i][j]=mat[i][col-j-1];
					mat[i][col-j-1]=temp;
				}
			}
		} else {
			row=mat.length;
			for (int i = 0; i < mat.length/2; i++) {
				col=mat[i].length;
				for (int j = 0; j < mat[i].length; j++) {
					temp=mat[i][j];
					mat[i][j]=mat[row-i-1][j];
					mat[row-i-1][j]=temp;
				}
			}
		}
		for (int i = 0; i < mat.length; i++) {
			for (int j = 0; j < mat[i].length; j++) {
				System.out.printf("%d ", mat[i][j]);
			}
			System.out.println();
		}
		sc.close();
	}
}
